<?php 
/**
*小区销售数据
*/
require("./include/init.php");
// print_r($data);
// exit;

$address=$_REQUEST['address'];
date_default_timezone_set('Asia/Shanghai');
//获取销量统计
// $sql="select * from xssj where xid=1";
$mysql=mysql::getIns();
// $row=$mysql->getOne($sql);
//获取进店频次等信息
// $sql="select * from xszj where xid=1";
// $mysql=mysql::getIns();
// $data=$mysql->getOne($sql);



/*************************************

	进店频次(每天统计一次,今天累计人数的进店频次)


************************************/
//统计当天累计人数数
$t = time();
$start = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));
$end = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t));
$sql="select count(*) from alldev where whitelist <> '1' and timestamp > $start and timestamp < $end and shop='". $address ."'";
$allday=$mysql->getOne($sql);

//统计进店频次为2次的
$sql="select count(*) from alldev where whitelist <> '1' and timestamp > $start and timestamp < $end  and visittimes='2' and shop='". $address ."'";
$visittwo=$mysql->getOne($sql);
// echo $visittwo;
// exit;

//统计进店频次为3次
$sql="select count(*) from alldev where whitelist <> '1' and timestamp > $start and timestamp < $end  and visittimes='3' and shop='". $address ."'";
$visitthree=$mysql->getOne($sql);
// echo $visitthree;
// exit;



//统计进店频次为3次以上
$sql="select count(*) from alldev where whitelist <> '1' and timestamp > $start and timestamp < $end  and visittimes > '3' and shop='". $address ."'";
$visitmore=$mysql->getOne($sql);
// echo $visitmore;
// exit;

//计算频次

//两次
$vtwo=ceil(($visittwo/$allday)*100);
// echo $vtwo;
// exit;
//三次
$vthree=ceil(($visitthree/$allday)*100);
// echo $vthree;
// exit;

//三次以上
$vmore=ceil(($visitmore/$allday)*100);
// echo $vmore;
// exit;

//一次
$vone=100-$vtwo-$vthree-$vmore;
// echo $vone;
// exit;
require(ROOT . 'view/iwocar5/SubArea_SaleDirector.html');
 ?>